package com.xujicheng.designpattern.learn.strategyPattern;


public class MovieTicket {
    private double price;
    private String type;

    //计算打折之后的票价
    public double calculate(){
        if(this.type.equalsIgnoreCase("student")){
            System.out.println("学生票：");
            return this.price * 0.8;
        }
        else if(this.type.equalsIgnoreCase("children") && this.price >=20){
            System.out.println("儿童票：");
            return this.price -10;
        }
        else if(this.type.equalsIgnoreCase("vip")){
            System.out.println("VIP票：");
            System.out.println("增加积分！");
            return this.price * 0.5;

        }else{
            return this.price; //如果不满足任何打折要求，则返回原始票价
        }
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }
}
